unit uLoginVCL;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.jpeg, Vcl.ExtCtrls,
  Vcl.StdCtrls, Vcl.MPlayer;

type
  TUsuarios = record
    Nombre: String;
    Password: String;
  end;

type
  TfmLogin = class(TForm)
    btnConectar: TButton;
    lblUsuario: TLabel;
    lblContrasena: TLabel;
    edUsuario: TEdit;
    edContrasena: TEdit;
    imgLogoPlus: TImage;
    procedure btnConectarClick(Sender: TObject);
    procedure edUsuarioKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure edContrasenaKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    Usuarios: array [0 .. 2] of TUsuarios;
    { Public declarations }
  end;

var
  fmLogin: TfmLogin;

implementation

{$R *.dfm}

uses uMainVCL;

procedure TfmLogin.btnConectarClick(Sender: TObject);
var
  i: Integer;
begin
  Usuarios[0].Nombre := 'GINES';
  Usuarios[1].Nombre := 'MARIANO';
  Usuarios[2].Nombre := 'MIGUEL';
  Usuarios[0].Password := 'DIGITAL';
  Usuarios[1].Password := 'DIGITAL';
  Usuarios[2].Password := '';

  for i := 0 to 2 do
  Begin
    if (UpperCase(Usuarios[i].Nombre) = UpperCase(edUsuario.Text)) and
      (UpperCase(Usuarios[i].Password) = UpperCase(edContrasena.Text)) then
    Begin
      Application.CreateForm(TFmPrincipal, FmPrincipal);
      FmLogin.Visible := False;
      FmPrincipal.ShowModal;
    End;
  end;
end;

procedure TfmLogin.edContrasenaKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = vk_Return then
    btnConectarClick(self);
end;

procedure TfmLogin.edUsuarioKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = vk_Return then
    btnConectarClick(self);
end;

end.
